/**
 * @file src/KTurnMotif.h
 *
 * @date 22-may-2013
 *
 * @author Youri Hoogstrate
 * @author Lisa Yu
 *
 * @section LICENSE
 * yh-kt-fold can predict RNA 2D structures including K-turns.
 * Copyright (C) 2012-2013 Youri Hoogstrate
 *
 * This file is part of yh-kt-fold.
 *
 * yh-kt-fold is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * yh-kt-fold is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */



#include "main.h"
#include "Functions/library.h"



/**
 * @brief This class stores (K-turn) motifs and their parameters.
 *
 * @section DESCRIPTION
 * Stores all (K-turn) motifs in memory. In the
 * Vij() function each of the K-turn objects is called and matched using
 * obj->match(). If it is returning true the energy is taken using
 * obj->getEnergy(). Storage of all K-turnsmotifs in the ReadData class
 * is now done linearly. This could be improved by using tree-like
 * structures based on the 5p and 3p length as key.
 * The match function matches in FASTA format so sequences not only
 * A C T/U G are allowed in motifs but also others like N/W/S/P. More
 * info can be found at:
 * http://en.wikipedia.org/wiki/FASTA_format
 *
 * @todo Change name of "clr()"
 * @todo Convert this in a STRUCT since it should only maintain data.
 *
 * @date 22-may-2013
 */
class KTurnMotif
{
	private:
		char motif5p[16];
		char motif3p[16]; // Is a reverse sequence -> check K-turn file
		
		char *motif5pP;// Use pointers instead of fixed size arrays
		char *motif3pP;// Use pointers instead of fixed size arrays
		
		float energy;
		
		//char binarySearchKey; getSize(5) <-- binary 4 digit; upto 16, getSize(3) <-- upto 4 binary digit and add it
		
	public:
		//
		int id;// TEMPORARY
		
		// Get Functions:
		int   getSize(int arg_prime);
		float getEnergy();
		//void  getMotif(int prime, char _str[]);
		
		// Set functions:
		void setKTurn(char arg_name[], char arg_motif5p[], char arg_motif3p[], char arg_bonds[], float arg_energy);
		
		// Reset functions:
		void reset();
		
		// Match functions:
		bool matchSequence(char arg_motif[], int arg_prime);
		bool matchBond(char arg_char1, char arg_char2, char arg_bond);
		bool match(char arg_motif5p[], char arg_motif3p[]);
		
		// Debug functions:
		void print();
		
		// Should become private one day, and accessable using a get-function
		int  motif5pBonds[16];// position in motif3p
		char motif5pBondTypes[16];// '|','+' or ':',..
		char name[32];
};
